package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.service.StudentService;
import cn.kgc.springcloud.vo.StudentRequestVo;
import cn.kgc.springcloud.vo.StudentResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/students")
public class StudentController {
    @Autowired
    private StudentService studentService;
    //查询学生列表
    @GetMapping
    public List<StudentResponseVo> queryAll(){
        return studentService.queryAll();
    }

    //添加学生
    @PostMapping
    public StudentResponseVo insert(@RequestBody StudentRequestVo studentRequestVo){
        StudentResponseVo studentResponseVo=studentService.insert(studentRequestVo);
        return studentResponseVo;
    }
}
